package cn.lvxs.freeeast.base_System;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;

import org.apache.catalina.core.ApplicationContext;

import cn.lvxs.framework.Application;
import cn.lvxs.framework.SystemConfig;

import com.wabacus.config.ConfigLoadManager;
import com.wabacus.config.component.application.report.ReportBean;
import com.wabacus.system.ReportRequest;
import com.wabacus.system.intercept.AbsInterceptorDefaultAdapter;
import com.wabacus.util.DesEncryptTools;

public class Interceptor_SaveSysConfig extends AbsInterceptorDefaultAdapter
{
    public int beforeSavePerRow(ReportRequest rrequest,ReportBean rbean,Map mRowData,Map mExternalValues,int updatetype)
    {
    	if(mRowData!=null)//mRowData中存放了本条记录各列的值
        {
    		SystemConfig sysConfig = new SystemConfig();
    		sysConfig.setId(Long.parseLong((String) mRowData.get("ID")));
    		sysConfig.setAllowfailtimes(Long.parseLong((String) mRowData.get("allowfailtimes")));
    		sysConfig.setAllowoldpassword(Long.parseLong((String)mRowData.get("allowoldpassword"))== 1);
    		sysConfig.setAutolockdays(Long.parseLong((String) mRowData.get("autolockdays")));
    		sysConfig.setInitpassword((String)mRowData.get("initpassword"));
    		sysConfig.setMeantimelogin(Long.parseLong((String) mRowData.get("meantimelogin")));
    		sysConfig.setPassingscore(Long.parseLong((String) mRowData.get("passingscore")));
    		sysConfig.setReminddays(Long.parseLong((String) mRowData.get("reminddays")));
    		sysConfig.setValiddays(Long.parseLong((String) mRowData.get("validdays")));
    		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    		try {
				sysConfig.setUpdatetime(sdf.parse((String) mRowData.get("updatetime")));
			} catch (ParseException e) {
			}
    		sysConfig.setUpdateusername((String)mRowData.get("CurrentUserName"));
    		Application.put("sysConfig",sysConfig);
        }
        return WX_CONTINUE;
    }

    public int afterSavePerRow(ReportRequest rrequest,ReportBean rbean,Map mRowData,Map mExternalValues,int updatetype)
    {
        return WX_CONTINUE;
    }

}
